import math
import util
DEG_2_RAD = (math.pi / 180.0)
RAD_2_DEG = (180.0 / math.pi)

def LtoI(v):
    if (v < 2147483648L):
        return int(v)
    else:
        return ~int((~v & 4294967295L))



def LerpList(color1, color2, lerpValue):
    invLerpValue = (1.0 - lerpValue)
    return [((invLerpValue * color1[0]) + (lerpValue * color2[0])),
     ((invLerpValue * color1[1]) + (lerpValue * color2[1])),
     ((invLerpValue * color1[2]) + (lerpValue * color2[2])),
     ((invLerpValue * color1[3]) + (lerpValue * color2[3]))]



def LerpVector(v1, v2, s):
    v = v1.CopyTo()
    v.Lerp(v2, s)
    return v



def Lerp(min, max, s):
    return (min + (s * (max - min)))



def LerpTupleThree(tuple1, tuple2, scaling):
    return (Lerp(tuple1[0], tuple2[0], scaling),
     Lerp(tuple1[1], tuple2[1], scaling),
     Lerp(tuple1[2], tuple2[2], scaling))



def LerpTupleFour(tuple1, tuple2, scaling):
    return (Lerp(tuple1[0], tuple2[0], scaling),
     Lerp(tuple1[1], tuple2[1], scaling),
     Lerp(tuple1[2], tuple2[2], scaling),
     Lerp(tuple1[3], tuple2[3], scaling))



def LerpByTime(startVal, endVal, startTime, endTime, curTime):
    lerpRatio = (float((curTime - startTime)) / float((endTime - startTime)))
    return Lerp(startVal, endVal, lerpRatio)



def DegToRad(degs):
    return (degs * DEG_2_RAD)



def RadToDeg(degs):
    return (degs * RAD_2_DEG)


exports = util.AutoExports('mathUtil', locals())

